package com.itheima.sh.controller;

import com.itheima.sh.pojo.Man;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description:
 * @Version: V1.0
 */
@RestController
public class HelloController {


    @Value("${company1}")
    private String company1;

    @Value("${company2}")
    private String company2;


    @GetMapping("hello")  // get 请求
    public String hello() {
        return "Hello SpringBoot !!! company1= " + company1 +"  company2="+company2;
    }


    @Value("${person.name}")
    private String name;
    //获取数组
    @Value("${address[0]}")
    private String address1;
    @Value("${address[1]}")
    private String address2;
    //获取纯量
    @Value("${msg1}")
    private String msg1;
    //获取纯量
    @Value("${msg2}")
    private String msg2;

    @Autowired
    private Man man;


    @GetMapping("getValue")
    public Man getValue() {
        System.out.println("name: "+name);
        System.out.println("address1: "+address1);
        System.out.println("address2: "+address2);
        System.out.println("msg1: "+msg1);
        System.out.println("msg2: "+msg2);

        return man;
    }

}
